using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IsometricEngine;
using Microsoft.Xna.Framework;
using Fated.Character;
using Fated.Scenario.Events;

namespace Fated.Scenario {
    class MessageBox : Renderable {
        private int currentLine = 0;
        private bool moreBelow;
        private Message data;

        public MessageBox(Message input) : base() {
            data = input;

            data.text = replaceKeywords(data.text);
            data.text = wordWrap(data.text, screenSize.X * textWidth);

            string temp = "";
            moreBelow = 1 == clipText(data.text, ref temp, screenSize.X * textWidth, screenSize.Y * textHeight, 0);
            this.text = temp;

            this.textPos = screenSize * new Vector2((1 - textWidth) / 2, (1 - textHeight));
        }
        public void updateText(Vector2 leftStick) {

            if (leftStick.Y > 0) currentLine--;
            if (leftStick.Y < 0 && moreBelow) currentLine++;
            if (currentLine < 0) currentLine = 0;

            string temp = "";
            moreBelow = 1 == clipText(data.text, ref temp, screenSize.X * textWidth, screenSize.Y * textHeight, currentLine);
            this.text = temp;
        }
        protected string replaceKeywords(string input) {
            string output = input.Replace("%player%", CurrentCharacter.Name);
            //output = input.Replace("%gender%", FatedGame.currentCharacter.gender);
            return output;
        }
    }
}
